#ifdef _MSC_VER
/*
 * we do not want the warnings about the old deprecated and unsecure CRT functions
 * since these examples can be compiled under *nix as well
 */
#define _CRT_SECURE_NO_WARNINGS
#endif


#include "stdafx.h"
#include "JHComm.h"
#include "JHZk.h"


int main()
{
	HANDLE hdl;
	JHINFO_SERIALPORT JHInfo_serialport;
	int ret;

	/* Create instance */
	JHCreateInst(&hdl, 0);
	if (NULL == hdl)
	{
		printf("\nFailure to create instance!\n");
		return -1;
	}

	/* Communication mode and parameters setting */
	JHInfo_serialport.size = sizeof(JHINFO_SERIALPORT);
	memcpy(JHInfo_serialport.serialport, "COM1", 5);
	JHInfo_serialport.baudrate = 115200;
	JHInfo_serialport.databits = 8;
	JHInfo_serialport.parity = 0;
	JHInfo_serialport.stopbits = 0;
	JHInfo_serialport.reserved = 0;
	JHInfo_serialport.timeout = 5000;
	JHMountTransportLayer(hdl, &JHTransportlayer_serialport, (const void *)(&JHInfo_serialport));

	/* Delete power on event operation*/
	JHZRESULT res = JHEventPoweronDelete(hdl);
	if (JR_OK == res)
	{
		printf("\nSuccessed in deleting power on event!\n");
		ret = 0;
	}
	else
	{
		printf("\nFailure to delete power on event!\n");
		ret = -1;
	}

	/* Delete instance */
	JHDeleteInst(hdl);

	Sleep(2000);

	return ret;
}

